/***************************************************************************
 *   Copyright (C) 2007 by Grzegorz Latarowski   *
 *   g.latarowski@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#ifndef ROIITEM_H
#define ROIITEM_H


// Qt
#include <QtGui>
#include <QList>



class GROI;



// ---------------------------- GROINode{} -----------------------------------
// ---------------------------------------------------------------------------
class GROINode : public QObject, public QGraphicsItem
{
    Q_OBJECT
            
public:
    GROINode( GROI * pROI );
    ~GROINode();
    
    QRectF boundingRect() const;
    QPainterPath shape() const;
    
    virtual void paint( QPainter * pPainter,
                        const QStyleOptionGraphicsItem * option,
                        QWidget * widget );
    
    
protected:
    virtual void mouseMoveEvent( QGraphicsSceneMouseEvent * event );
    
    
private:
    GROI * _pROI;
    
}; // class !GROINode
// ---------------------------------------------------------------------------





// ---------------------------- GROI{} ---------------------------------------
// ---------------------------------------------------------------------------
class GROI : public QObject, public QGraphicsItem
{
    Q_OBJECT

public:

        // construtors
    GROI( QGraphicsPixmapItem * pPixmapItem );
    ~GROI();
    
    QRectF boundingRect() const;
    QPainterPath shape() const;
    void paint( QPainter * pPainter,
                const QStyleOptionGraphicsItem * pOption,
                QWidget * widget
              );

    void adjust();
    void addChildToScene();
    
    QList< GROINode * > & nodeList() { return _nodeList; }

private:
    QGraphicsPixmapItem * _pPixmapItem;
    QList< GROINode * >   _nodeList;
    QPolygonF             _roi;
    

}; // class !GROI
// ---------------------------------------------------------------------------





#endif // !ROIITEM_H






// eof
